package cas.ihep.spark.io;

import java.io.DataInput;
import java.io.DataOutput;
import java.util.concurrent.ConcurrentHashMap;

public interface Serializer{
    int length(Object data);
    void serialize(Object data, DataOutput output);
    Object deserialize(DataInput input);
    static void registerHandler(Class<?> cls, Serializer s){
        handler.put(cls,s);
    }
    static Serializer findHandler(Class<?> cls){return handler.get(cls);}
    ConcurrentHashMap<Class<?>,Serializer> handler=new ConcurrentHashMap<>();
}
